﻿
@{
    Layout = null;
}


<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>申请管理</title>
    @Styles.Render("~/Content/easyui")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/easyui")
    <style type="text/css">
      

        #fm {
            margin: 0;
            padding: 10px 30px;
        }

        .ftitle {
            font-size: 14px;
            font-weight: bold;
            padding: 5px 0;
            margin-bottom: 10px;
            border-bottom: 1px solid #ccc;
        }

        .fitem {
            margin-bottom: 5px;
        }

            .fitem label {
                display: inline-block;
                width: 100px;
            }

            .fitem input {
                width: 160px;
            }
    </style>
    </head>
    <body>
        <div id="cc" class="easyui-layout" fit="true">
            <div data-options="region:'north',split:true,border:false" style="padding:5px;" fit="true">
                <table style="margin:10px" class="easyui-datagrid" id="dg" title="我的申请" data-options="singleSelect:true,collapsible:true,url:'/ItService/AllWorkFlowList',method:'post',fit:true,rownumbers:'true',pagination:'true',toolbar:'#toolbar'">
                    <thead>
                        <tr>
                            <th data-options="field:'WfTitle',width:500,align:'center'">标题</th>
                            <th data-options="field:'WfType',width:140,align:'center'">类型</th>
                            <th data-options="field:'WfDrafter',width:140,align:'center'">起草人</th>
                            <th data-options="field:'WfApplicant',width:140,align:'center'">申请人</th>
                            <th data-options="field:'Wfstatus',width:140,align:'center'">当前状态</th>
                            <th data-options="field:'WfCreateDate',width:200,align:'center'">日期</th>
                        </tr>
                    </thead>
                </table>
            </div>
         </div>
        <div id="toolbar">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="ViewWorkFlow()">查看</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="DelWorkFlow()" id="bdel">删除</a>
        </div>
            <script language="javascript">
                function ViewWorkFlow() {
                    var row = $('#dg').datagrid('getSelected');
                    if (row) {
                        var jq = top.jQuery;
                        if (jq('#tt').tabs('exists', row.WfTitle)) {
                            jq('#tt').tabs('select', row.WfTitle);
                        } else {
                            var content = '<iframe scrolling="auto" id="' + row.WfCurrentUser + '" frameborder="0"  src="/ItService/ViewWorkFlow?id=' + row.WfInstanceId + '" style="width:100%;height:100%;"></iframe>';
                            jq('#tt').tabs('add', {
                                title: row.WfTitle,
                                content: content,
                                closable: true,
                                icon: 'icon_todo',
                            });
                        }

                    }
                }

                function DelWorkFlow() {
                    var node = $('#dg').datagrid('getSelected');
                    if (node) {
                        $.messager.confirm('Confirm', '确定要删除这个流程吗?', function (r) {
                            if (r) {
                                $.post('/ItService/DelWorkFlow ', { id: node.WfInstanceId }, function (result) {
                                    if (result.okMsg) {
                                        $('#dg').datagrid('reload');
                                        $.messager.show({	// show error message
                                            title: '删除成功',
                                            msg: result.okMsg
                                        });
                                        // reload the user data
                                    } else {
                                        $.messager.show({	// show error message
                                            title: '删除失败',
                                            msg: result.errorMsg
                                        });
                                    }

                                }, 'json');
                            }
                        });
                    }
                }



                $(function () {
                    var p = $('#dg').datagrid('getPager');

                    $(p).pagination({

                        pageSize: 10,//每页显示的记录条数，默认为10

                        pageList: [10, 20, 30],//可以设置每页记录条数的列表

                        beforePageText: '第',//页数文本框前显示的汉字

                        afterPageText: '页    共 {pages} 页',

                        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',

                        /*onBeforeRefresh:function(){

                            $(this).pagination('loading');

                            alert('before refresh');

                            $(this).pagination('loaded');

                        }*/

                    });
                });

            </script>
</body>

</html>